package com.sumainfor.pc.epc.controller.cfoProvider;

import com.sumainfor.pc.epc.service.SupplierProviderService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author Eddy·Chen
 * @Email 835033913@qq.com
 * @Create 2019-04-17 18:53
 */
@RestController
@RequestMapping("/provider/key/supplier")
public class SupplierProviderController {

    @Autowired
    private SupplierProviderService sps;

    /**
     * 财务部查询供应商账单数据
     *
     * @param remitId
     * @return
     */
    @PostMapping("/getSupplierOrderInfoForRemit")
    public Map<String, Object> getSupplierOrderInfoForRemit(String remitId) {
        if (StringUtils.isBlank(remitId)) {
            return null;
        }
        return sps.getSupplierOrderInfoForRemit(remitId);
    }


    /**
     * 筛选供应商 工具打款编号进行筛选出来
     *
     * @param params :supName 搜索的名字
     *               :remitIds 申请编号List
     * @return
     */
    @PostMapping("/searchSupNameToRemitIds")
    public List<String> searchSupNameToRemitIds(@RequestBody Map<String, Object> params) {
        String supName = (String) params.get("supName");
        List<String> remitIds = (List<String>) params.get("remitIds");
        if (StringUtils.isBlank(supName) || CollectionUtils.isEmpty(remitIds)) {
            return null;
        }
        return sps.searchSupNameToRemitIds(supName, remitIds);
    }


}
